package com.example.speedwaymanager;

import java.util.Collections;
import java.util.Comparator;

/**
 * Created by Lukas on 09.10.13.
 */
public class CHomeTeam extends CTeam {
    /**
     * constructs a team with name REMARK: to add riders call addRiderToTeam()
     *
     * @param name name of the home team
     */
    public CHomeTeam(String name) {
        super(name);
    }

    public CHomeTeam(CTeam team) {
        super(team);
    }

    @Override
    public Boolean is_HomeTeam() {
        return true;
    }

    /**
     * sets home squad based on home avg
     */
    @Override
    public void createSquad() {
        Collections.sort(_seniorRiders, new ridersAvgHomeComparator());
        Collections.sort(_juniorRiders, new ridersAvgHomeComparator());
        squad();
    }
}

final class ridersAvgHomeComparator implements Comparator<CRider> {
    @Override
    public int compare(CRider r1, CRider r2) {
        return r1.get_avgHome().compareTo(r2.get_avgHome());
    }
}